{extend name="public/base"}
{block name='main'}
<style type="text/css">
    .adimg {margin-top: 10px;}
</style>
<!--编辑菜单-->
<form class="layui-form layui-form-pane" action="" style="padding:20px;">
    <div class="layui-form-item">
        <label class="layui-form-label">{$info.id|default=''}幻灯片名称</label>
        <div class="layui-input-block">
            <input type="text" name="name" id="name" placeholder="请输入" class="layui-input" value="{$info.name|default=''}">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">幻灯片链接</label>
        <div class="layui-input-block">
            <input type="text" name="url" id="url" placeholder="请输入" class="layui-input" value="{$info.url|default=''}">
        </div>
    </div>

    <div class="layui-form-item" id="slide_image">
        <label class="layui-form-label">幻灯片图片</label>
        <div class="layui-input-block">
            <button type="button" name="img1" class="layui-btn layui-btn-primary" id="upimg">
                <i class="layui-icon"></i>只允许图片文件</button>
            <div class="layui-form-mid " style="width: 100%">
                <img src={eq name="$info.img|default=''" value=''}{else/}{:upload_url($info['img'], 'slide')}{/eq}  height="36" id="imgval" >
            </div>
        </div>

    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">排序值</label>
        <div class="layui-input-block">
            <input type="number" name="ordid" id="ordid" placeholder="请输入" class="layui-input" value="{$info.ordid|default='0'}">
        </div>
    </div>

    <div class="layui-form-item">
        <label class=""></label>
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="content_edit">提交保存</button>
        </div>
    </div>
    <input type="hidden" name="img" id="J_img" value="{$info.img|default=''}">
    <input type="hidden" name="id" id="id" value="{$info.id|default=''}" />
</form>
<script type="text/javascript" src="__PUBLIC__/admin/layui/layui.js"></script>
<script>
    //Demo
    layui.use(['layer','jquery','form','upload'], function () {
        // 操作对象
        var layer = layui.layer,$ = layui.jquery,form = layui.form, upload = layui.upload;


        //上传图片
        upload.render({
            elem: '#upimg'
            ,url: "{:url('slide/ajax_upload_img')}"
            ,field:'file'
            ,acceptMime: 'image/*'
            ,done: function(res, index, upload){
                if (res.status == 1) {
                    layer.msg('上传成功',{time:1800});
                    $('#J_img').val(res.info);
                    $('#imgval').show().attr('src',res.img_url);
                }else {
                    layer.msg('上传失败',{time:1800});
                }
            }
        });
        Oper.initUpdate(layui, '幻灯片', 'content_edit', 'slide/edit');
    });
</script>
{/block}